package com.csx.saas.platform.system.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.csx.basic.base.entity.TreeEntity;
import com.csx.saas.platform.system.enumeration.SystemMenuTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import java.time.LocalDateTime;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 菜单
 * </p>
 *
 * @author ChenSongXin
 * @since 2021-02-28
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("saas_system_menu")
@ApiModel(value = "SystemMenu", description = "菜单")
@AllArgsConstructor
public class SystemMenu extends TreeEntity<SystemMenu, Long> {

    private static final long serialVersionUID = 1L;

    /**
     * 描述
     */
    @ApiModelProperty(value = "描述")
    @Length(max = 200, message = "描述长度不能超过200")
    @TableField(value = "describe_", condition = LIKE)
    @Excel(name = "描述")
    private String describe;

    /**
     * 权限标记
     */
    @ApiModelProperty(value = "权限标记")
    @Length(max = 20, message = "权限标记长度不能超过20")
    @TableField(value = "resource_sign", condition = LIKE)
    @Excel(name = "权限标记")
    private String resourceSign;

    /**
     * 路径
     */
    @ApiModelProperty(value = "路径")
    @Length(max = 255, message = "路径长度不能超过255")
    @TableField(value = "path", condition = LIKE)
    @Excel(name = "路径")
    private String path;

    /**
     * 组件
     */
    @ApiModelProperty(value = "组件")
    @Length(max = 255, message = "组件长度不能超过255")
    @TableField(value = "component", condition = LIKE)
    @Excel(name = "组件")
    private String component;

    /**
     * 菜单图标
     */
    @ApiModelProperty(value = "菜单图标")
    @Length(max = 255, message = "菜单图标长度不能超过255")
    @TableField(value = "icon", condition = LIKE)
    @Excel(name = "菜单图标")
    private String icon;

    /**
     * 菜单类型\n#{MENU:菜单;OPERATION:操作权限;}
     */
    @ApiModelProperty(value = "菜单类型\n#{MENU:菜单;OPERATION:操作权限;}")
    @TableField("type")
    @Excel(name = "菜单类型\n#{MENU:菜单;OPERATION:操作权限;}", replace = {"菜单_MENU", "操作权限_OPERATION",  "_null"})
    private SystemMenuTypeEnum type;

    /**
     * 菜单 0隐藏 1显示
     */
    @ApiModelProperty(value = "菜单 0隐藏 1显示")
    @TableField("hidden")
    @Excel(name = "菜单 0隐藏 1显示", replace = {"是_true", "否_false", "_null"})
    private Boolean hidden;

    @ApiModelProperty(value = "上级名称")
    @TableField(exist = false)
    private String parentName;


    @Builder
    public SystemMenu(Long id, String label, Integer sortValue, Long parentId, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime, 
                    String describe, String resourceSign, String path, String component, String icon, 
                    SystemMenuTypeEnum type, Boolean hidden) {
        this.id = id;
        this.label = label;
        this.sortValue = sortValue;
        this.parentId = parentId;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.describe = describe;
        this.resourceSign = resourceSign;
        this.path = path;
        this.component = component;
        this.icon = icon;
        this.type = type;
        this.hidden = hidden;
    }

}
